<?php
   
    $menuName = __('Related Companies', true);
    $hMenuName = $this->Html->tag('h2', $menuName, array('class' => 'title'));
    $viewAll = $this->Html->tag('span', $this->Html->link(__('See all', true), sprintf('/companies/category/%s/%s',$relatedCompanies[0]['Classification']['name'], $relatedCompanies[0]['Classification']['id'])));

    //wrap company
    $div = '';
    $push = 0;
    $allRelated = '';
    foreach($relatedCompanies as $rc){
        if($rc['Company']['logo_48'])
            $image = $this->Html->image($rc['Company']['logo_48'], array('width' => 48, 'height' => 48, 'url' => $rc['Company']['slug']));
        else
          $image = $this->Html->image('/files/company/logo/default_48.png', array('width' => 48, 'height' => 48, 'url' => $rc['Company']['slug']));
        
        $div .= $this->Html->div('related-company-content', $image . $this->Html->link($rc['Company']['name'], $rc['Company']['slug'], array('class' => 'text-link')));
        $push++;
        if($push == 3){
            $allRelated .= $this->Html->div('related-company clearfix', $div);
            $div = '';
            $push = 0;
        }
       
    }
    if($push > 0)
        $allRelated .= $this->Html->div('related-company clearfix', $div);
    //$allRelated .= $this->Html->div('related-company clearfix', $div);

    echo $this->Html->tag('div',  $hMenuName.$viewAll.$allRelated, array('id' => 'related_company'));
?>
